package com.title1;

import java.io.BufferedInputStream;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.concurrent.*;

/**
 * @Author milian
 * @Date 2021/8/10 0010 19:35
 */
public class serverSocket {
    public static void main(String[] args) throws IOException {
//        1. 将上课讲的网络编程案例：文件上传线程池最终版，实现一遍。
        ServerSocket serverSocket = new ServerSocket(10000);
        ThreadPoolExecutor poolExecutor = new ThreadPoolExecutor(5,
                10,
                60,
                TimeUnit.SECONDS,
                new ArrayBlockingQueue<>(2),
                Executors.defaultThreadFactory(),
                new ThreadPoolExecutor.AbortPolicy());
        while (true){
            Socket accept = serverSocket.accept();
            uploadThread uploadThread = new uploadThread(accept);
            poolExecutor.submit(uploadThread);
        }
    }
}
